package work;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import util.ConnectionRabbitMQ;

public class Sender {
    public static void main(String[] args) throws Exception {

        // 1.获得连接
        Connection connection = ConnectionRabbitMQ.getConnection();
        // 2.在连接中创建通道
        Channel channel = connection.createChannel();
        // 3.创建消息队列(1,2,3,4,5)
        channel.queueDeclare("test_work_queue",false,false,false,null);
        // 4.向指定的队列发送消息(1,2,3,4)
        for(int i=1;i<=100;i++){
            String msg = "羊肉串-->"+i;

            channel.basicPublish("","test_work_queue",null,msg.getBytes());
            System.out.println("吃掉:"+msg);
        }
        // 5.释放资源
        channel.close();
        connection.close();
    }
}
